package demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86138
 * Date: 2024-06-04
 * Time: 8:21
 */
public class Animal {
    //成员变量
    public String name;
    public int age;



    //构造方法
    public Animal(String name, int age){
        this.name = name;
        this.age = age;
    }


    public void eat(){
        System.out.println(this.name + "哐哐吃");
    }




    public String getName(){
        return name;
    }

    public int getAge(){
        return age;
    }

    public void setName(String name){
        this.name = name;
    }

    public void setAge(int age){
        this.age = age;
    }






    //重写toString
    @Override
    public String toString() {
        return "Dog{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
